<?php
/**
* Moossenger Joomla! Module
*
* @author    g. henson
* @copyright Copyright (C) 2008 g. henson All rights reserved.
* @license	 GNU/GPL
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

if (!$my->id > 0) {
	mosNotAuth();
	return;
}

if ($my->id) {
	// je suis connecte, je peux acceder a ce module
	$return = "";
	$modmoossenger_path = "$mosConfig_live_site/modules/mod_moossenger";
	
	$moosWindooStyle = $params->get('MoosWindooStyle', 'aero');
	$return = '	<link type="text/css" rel="stylesheet" href="'.$modmoossenger_path.'/themes/menus2.css"></link>
				<link type="text/css" rel="stylesheet" href="'.$modmoossenger_path.'/themes/style.css"></link>
				<style type="text/css" media="all">
					/* include common CSS file */
					@import url('.$modmoossenger_path.'/themes/windoo/windoo.css);
				
					/* include theme-specific CSS files */
					@import url('.$modmoossenger_path.'/themes/windoo/windoo.'.$moosWindooStyle.'.css);
					
					body {
						background:#fff;
					}
				</style>
				<script src="'.$modmoossenger_path.'/js/config.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/mootools-release-1.11.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/windoo.r114.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/tools.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/user.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/message.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/toolbar.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/moossenger.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/im.manager.js" type="text/javascript" charset="utf-8"></script>			
				<script src="'.$modmoossenger_path.'/js/languages.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/js/system.js" type="text/javascript" charset="utf-8"></script>
				<script src="'.$modmoossenger_path.'/themes/default/emoticons/emoticons.js" type="text/javascript" charset="utf-8"></script>';
				
				$filelangpath = str_replace('\\', '/', $mosConfig_absolute_path).'/modules/mod_moossenger/languages/'.$mosConfig_lang.'/lang.js';
				if (file_exists($filelangpath)) {
					$return = $return. '<script src="'.$modmoossenger_path.'/languages/'.$mosConfig_lang.'/lang.js" type="text/javascript" charset="ISO-8859-1"></script>';
				} else {	
					$return = $return. '<script src="'.$modmoossenger_path.'/languages/english/lang.js" type="text/javascript" charset="utf-8"></script>';
				}
	
				$return = $return.'<script type="text/javascript">
					var windooStyle = "'.$moosWindooStyle.'";
					var userlogin = '.$my->id.';
					var username = "'.$my->username.'";
					
					var interval;
					function startIn () {
						return setInterval(doaction, \'1500\');
					}
					function doaction () {
						System.ping(userlogin);
					}
					function stopIn() {
						clearInterval(interval);
					}
					
					window.addEvent(\'domready\', function() {
						imManager.getHTMLtpl();
						$(\'moosNochat\').innerHTML=Languages.get(\'no-current-chat\');
					});
				</script>
	
				<div id="moosmain">
					<br>
					<input type="button" title="start" value="start" onclick="interval = startIn();"/>
					<br>
					<input type="button" title="stop" value="stop" onclick="stopIn();"/>
					<br><br>
					<div id="moosNochat" style="display:block;"></div>
					<div id="mylist">
						<ul id="moosChatList">
						</ul>
					</div>
				</div>';
	
	echo $return;
}
   
?>